#include <mime.h>
#include <stdio.h>
#include <string.h>

const char* getMimeType(const char* filename)
{
  const char* extension = strrchr(filename, '.');
  if (extension != NULL)
  {
    if (strcmp(extension, ".323") == 0)
    {
      return "text/h323";
    }
    else if (strcmp(extension, ".acx") == 0)
    {
      return "application/internet-property-stream";
    }
    else if (strcmp(extension, ".ai") == 0)
    {
      return "application/postscript";
    }
    else if (strcmp(extension, ".aif") == 0)
    {
      return "audio/x-aiff";
    }
    else if (strcmp(extension, ".aifc") == 0)
    {
      return "audio/x-aiff";
    }
    else if (strcmp(extension, ".aiff") == 0)
    {
      return "audio/x-aiff";
    }
    else if (strcmp(extension, ".asf") == 0)
    {
      return "video/x-ms-asf";
    }
    else if (strcmp(extension, ".asr") == 0)
    {
      return "video/x-ms-asf";
    }
    else if (strcmp(extension, ".asx") == 0)
    {
      return "video/x-ms-asf";
    }
    else if (strcmp(extension, ".au") == 0)
    {
      return "audio/basic";
    }
    else if (strcmp(extension, ".avi") == 0)
    {
      return "video/x-msvideo";
    }
    else if (strcmp(extension, ".axs") == 0)
    {
      return "application/olescript";
    }
    else if (strcmp(extension, ".bas") == 0)
    {
      return "text/plain";
    }
    else if (strcmp(extension, ".bcpio") == 0)
    {
      return "application/x-bcpio";
    }
    else if (strcmp(extension, ".bin") == 0)
    {
      return "application/octet-stream";
    }
    else if (strcmp(extension, ".bmp") == 0)
    {
      return "image/bmp";
    }
    else if (strcmp(extension, ".c") == 0)
    {
      return "text/plain";
    }
    else if (strcmp(extension, ".cat") == 0)
    {
      return "application/vnd.ms-pkiseccat";
    }
    else if (strcmp(extension, ".cdf") == 0)
    {
      return "application/x-cdf";
    }
    else if (strcmp(extension, ".cer") == 0)
    {
      return "application/x-x509-ca-cert";
    }
    else if (strcmp(extension, ".class") == 0)
    {
      return "application/octet-stream";
    }
    else if (strcmp(extension, ".clp") == 0)
    {
      return "application/x-msclip";
    }
    else if (strcmp(extension, ".cmx") == 0)
    {
      return "image/x-cmx";
    }
    else if (strcmp(extension, ".cod") == 0)
    {
      return "image/cis-cod";
    }
    else if (strcmp(extension, ".cpio") == 0)
    {
      return "application/x-cpio";
    }
    else if (strcmp(extension, ".crd") == 0)
    {
      return "application/x-mscardfile";
    }
    else if (strcmp(extension, ".crl") == 0)
    {
      return "application/pkix-crl";
    }
    else if (strcmp(extension, ".crt") == 0)
    {
      return "application/x-x509-ca-cert";
    }
    else if (strcmp(extension, ".csh") == 0)
    {
      return "application/x-csh";
    }
    else if (strcmp(extension, ".css") == 0)
    {
      return "text/css";
    }
    else if (strcmp(extension, ".dcr") == 0)
    {
      return "application/x-director";
    }
    else if (strcmp(extension, ".der") == 0)
    {
      return "application/x-x509-ca-cert";
    }
    else if (strcmp(extension, ".dir") == 0)
    {
      return "application/x-director";
    }
    else if (strcmp(extension, ".dll") == 0)
    {
      return "application/x-msdownload";
    }
    else if (strcmp(extension, ".dms") == 0)
    {
      return "application/octet-stream";
    }
    else if (strcmp(extension, ".doc") == 0)
    {
      return "application/msword";
    }
    else if (strcmp(extension, ".dot") == 0)
    {
      return "application/msword";
    }
    else if (strcmp(extension, ".dvi") == 0)
    {
      return "application/x-dvi";
    }
    else if (strcmp(extension, ".dxr") == 0)
    {
      return "application/x-director";
    }
    else if (strcmp(extension, ".eps") == 0)
    {
      return "application/postscript";
    }
    else if (strcmp(extension, ".etx") == 0)
    {
      return "text/x-setext";
    }
    else if (strcmp(extension, ".evy") == 0)
    {
      return "application/envoy";
    }
    else if (strcmp(extension, ".exe") == 0)
    {
      return "application/octet-stream";
    }
    else if (strcmp(extension, ".fif") == 0)
    {
      return "application/fractals";
    }
    else if (strcmp(extension, ".flr") == 0)
    {
      return "x-world/x-vrml";
    }
    else if (strcmp(extension, ".gif") == 0)
    {
      return "image/gif";
    }
    else if (strcmp(extension, ".gtar") == 0)
    {
      return "application/x-gtar";
    }
    else if (strcmp(extension, ".gz") == 0)
    {
      return "application/x-gzip";
    }
    else if (strcmp(extension, ".h") == 0)
    {
      return "text/plain";
    }
    else if (strcmp(extension, ".hdf") == 0)
    {
      return "application/x-hdf";
    }
    else if (strcmp(extension, ".hlp") == 0)
    {
      return "application/winhlp";
    }
    else if (strcmp(extension, ".hqx") == 0)
    {
      return "application/mac-binhex40";
    }
    else if (strcmp(extension, ".hta") == 0)
    {
      return "application/hta";
    }
    else if (strcmp(extension, ".htc") == 0)
    {
      return "text/x-component";
    }
    else if (strcmp(extension, ".htm") == 0)
    {
      return "text/html";
    }
    else if (strcmp(extension, ".html") == 0)
    {
      return "text/html";
    }
    else if (strcmp(extension, ".htt") == 0)
    {
      return "text/webviewhtml";
    }
    else if (strcmp(extension, ".ico") == 0)
    {
      return "image/x-icon";
    }
    else if (strcmp(extension, ".ief") == 0)
    {
      return "image/ief";
    }
    else if (strcmp(extension, ".iii") == 0)
    {
      return "application/x-iphone";
    }
    else if (strcmp(extension, ".ins") == 0)
    {
      return "application/x-internet-signup";
    }
    else if (strcmp(extension, ".isp") == 0)
    {
      return "application/x-internet-signup";
    }
    else if (strcmp(extension, ".jfif") == 0)
    {
      return "image/pipeg";
    }
    else if (strcmp(extension, ".jpe") == 0)
    {
      return "image/jpeg";
    }
    else if (strcmp(extension, ".jpeg") == 0)
    {
      return "image/jpeg";
    }
    else if (strcmp(extension, ".jpg") == 0)
    {
      return "image/jpeg";
    }
    else if (strcmp(extension, ".js") == 0)
    {
      return "application/x-javascript";
    }
    else if (strcmp(extension, ".latex") == 0)
    {
      return "application/x-latex";
    }
    else if (strcmp(extension, ".lha") == 0)
    {
      return "application/octet-stream";
    }
    else if (strcmp(extension, ".lsf") == 0)
    {
      return "video/x-la-asf";
    }
    else if (strcmp(extension, ".lsx") == 0)
    {
      return "video/x-la-asf";
    }
    else if (strcmp(extension, ".lzh") == 0)
    {
      return "application/octet-stream";
    }
    else if (strcmp(extension, ".m13") == 0)
    {
      return "application/x-msmediaview";
    }
    else if (strcmp(extension, ".m14") == 0)
    {
      return "application/x-msmediaview";
    }
    else if (strcmp(extension, ".m3u") == 0)
    {
      return "audio/x-mpegurl";
    }
    else if (strcmp(extension, ".man") == 0)
    {
      return "application/x-troff-man";
    }
    else if (strcmp(extension, ".mdb") == 0)
    {
      return "application/x-msaccess";
    }
    else if (strcmp(extension, ".me") == 0)
    {
      return "application/x-troff-me";
    }
    else if (strcmp(extension, ".mht") == 0)
    {
      return "message/rfc822";
    }
    else if (strcmp(extension, ".mhtml") == 0)
    {
      return "message/rfc822";
    }
    else if (strcmp(extension, ".mid") == 0)
    {
      return "audio/mid";
    }
    else if (strcmp(extension, ".mny") == 0)
    {
      return "application/x-msmoney";
    }
    else if (strcmp(extension, ".mov") == 0)
    {
      return "video/quicktime";
    }
    else if (strcmp(extension, ".movie") == 0)
    {
      return "video/x-sgi-movie";
    }
    else if (strcmp(extension, ".mp2") == 0)
    {
      return "video/mpeg";
    }
    else if (strcmp(extension, ".mp3") == 0)
    {
      return "audio/mpeg";
    }
    else if (strcmp(extension, ".mpa") == 0)
    {
      return "video/mpeg";
    }
    else if (strcmp(extension, ".mpe") == 0)
    {
      return "video/mpeg";
    }
    else if (strcmp(extension, ".mpeg") == 0)
    {
      return "video/mpeg";
    }
    else if (strcmp(extension, ".mpg") == 0)
    {
      return "video/mpeg";
    }
    else if (strcmp(extension, ".mpp") == 0)
    {
      return "application/vnd.ms-project";
    }
    else if (strcmp(extension, ".mpv2") == 0)
    {
      return "video/mpeg";
    }
    else if (strcmp(extension, ".ms") == 0)
    {
      return "application/x-troff-ms";
    }
    else if (strcmp(extension, ".mvb") == 0)
    {
      return "application/x-msmediaview";
    }
    else if (strcmp(extension, ".nws") == 0)
    {
      return "message/rfc822";
    }
    else if (strcmp(extension, ".oda") == 0)
    {
      return "application/oda";
    }
    else if (strcmp(extension, ".p10") == 0)
    {
      return "application/pkcs10";
    }
    else if (strcmp(extension, ".p12") == 0)
    {
      return "application/x-pkcs12";
    }
    else if (strcmp(extension, ".p7b") == 0)
    {
      return "application/x-pkcs7-certificates";
    }
    else if (strcmp(extension, ".p7c") == 0)
    {
      return "application/x-pkcs7-mime";
    }
    else if (strcmp(extension, ".p7m") == 0)
    {
      return "application/x-pkcs7-mime";
    }
    else if (strcmp(extension, ".p7r") == 0)
    {
      return "application/x-pkcs7-certreqresp";
    }
    else if (strcmp(extension, ".p7s") == 0)
    {
      return "application/x-pkcs7-signature";
    }
    else if (strcmp(extension, ".pbm") == 0)
    {
      return "image/x-portable-bitmap";
    }
    else if (strcmp(extension, ".pdf") == 0)
    {
      return "application/pdf";
    }
    else if (strcmp(extension, ".pfx") == 0)
    {
      return "application/x-pkcs12";
    }
    else if (strcmp(extension, ".pgm") == 0)
    {
      return "image/x-portable-graymap";
    }
    else if (strcmp(extension, ".pko") == 0)
    {
      return "application/ynd.ms-pkipko";
    }
    else if (strcmp(extension, ".pma") == 0)
    {
      return "application/x-perfmon";
    }
    else if (strcmp(extension, ".pmc") == 0)
    {
      return "application/x-perfmon";
    }
    else if (strcmp(extension, ".pml") == 0)
    {
      return "application/x-perfmon";
    }
    else if (strcmp(extension, ".pmr") == 0)
    {
      return "application/x-perfmon";
    }
    else if (strcmp(extension, ".pmw") == 0)
    {
      return "application/x-perfmon";
    }
    else if (strcmp(extension, ".pnm") == 0)
    {
      return "image/x-portable-anymap";
    }
    else if (strcmp(extension, ".pot,") == 0)
    {
      return "application/vnd.ms-powerpoint";
    }
    else if (strcmp(extension, ".ppm") == 0)
    {
      return "image/x-portable-pixmap";
    }
    else if (strcmp(extension, ".pps") == 0)
    {
      return "application/vnd.ms-powerpoint";
    }
    else if (strcmp(extension, ".ppt") == 0)
    {
      return "application/vnd.ms-powerpoint";
    }
    else if (strcmp(extension, ".prf") == 0)
    {
      return "application/pics-rules";
    }
    else if (strcmp(extension, ".ps") == 0)
    {
      return "application/postscript";
    }
    else if (strcmp(extension, ".pub") == 0)
    {
      return "application/x-mspublisher";
    }
    else if (strcmp(extension, ".qt") == 0)
    {
      return "video/quicktime";
    }
    else if (strcmp(extension, ".ra") == 0)
    {
      return "audio/x-pn-realaudio";
    }
    else if (strcmp(extension, ".ram") == 0)
    {
      return "audio/x-pn-realaudio";
    }
    else if (strcmp(extension, ".ras") == 0)
    {
      return "image/x-cmu-raster";
    }
    else if (strcmp(extension, ".rgb") == 0)
    {
      return "image/x-rgb";
    }
    else if (strcmp(extension, ".rmi") == 0)
    {
      return "audio/mid";
    }
    else if (strcmp(extension, ".roff") == 0)
    {
      return "application/x-troff";
    }
    else if (strcmp(extension, ".rtf") == 0)
    {
      return "application/rtf";
    }
    else if (strcmp(extension, ".rtx") == 0)
    {
      return "text/richtext";
    }
    else if (strcmp(extension, ".scd") == 0)
    {
      return "application/x-msschedule";
    }
    else if (strcmp(extension, ".sct") == 0)
    {
      return "text/scriptlet";
    }
    else if (strcmp(extension, ".setpay") == 0)
    {
      return "application/set-payment-initiation";
    }
    else if (strcmp(extension, ".setreg") == 0)
    {
      return "application/set-registration-initiation";
    }
    else if (strcmp(extension, ".sh") == 0)
    {
      return "application/x-sh";
    }
    else if (strcmp(extension, ".shar") == 0)
    {
      return "application/x-shar";
    }
    else if (strcmp(extension, ".sit") == 0)
    {
      return "application/x-stuffit";
    }
    else if (strcmp(extension, ".snd") == 0)
    {
      return "audio/basic";
    }
    else if (strcmp(extension, ".spc") == 0)
    {
      return "application/x-pkcs7-certificates";
    }
    else if (strcmp(extension, ".spl") == 0)
    {
      return "application/futuresplash";
    }
    else if (strcmp(extension, ".src") == 0)
    {
      return "application/x-wais-source";
    }
    else if (strcmp(extension, ".sst") == 0)
    {
      return "application/vnd.ms-pkicertstore";
    }
    else if (strcmp(extension, ".stl") == 0)
    {
      return "application/vnd.ms-pkistl";
    }
    else if (strcmp(extension, ".stm") == 0)
    {
      return "text/html";
    }
    else if (strcmp(extension, ".svg") == 0)
    {
      return "image/svg+xml";
    }
    else if (strcmp(extension, ".sv4cpio") == 0)
    {
      return "application/x-sv4cpio";
    }
    else if (strcmp(extension, ".sv4crc") == 0)
    {
      return "application/x-sv4crc";
    }
    else if (strcmp(extension, ".swf") == 0)
    {
      return "application/x-shockwave-flash";
    }
    else if (strcmp(extension, ".t") == 0)
    {
      return "application/x-troff";
    }
    else if (strcmp(extension, ".tar") == 0)
    {
      return "application/x-tar";
    }
    else if (strcmp(extension, ".tcl") == 0)
    {
      return "application/x-tcl";
    }
    else if (strcmp(extension, ".tex") == 0)
    {
      return "application/x-tex";
    }
    else if (strcmp(extension, ".texi") == 0)
    {
      return "application/x-texinfo";
    }
    else if (strcmp(extension, ".texinfo") == 0)
    {
      return "application/x-texinfo";
    }
    else if (strcmp(extension, ".tgz") == 0)
    {
      return "application/x-compressed";
    }
    else if (strcmp(extension, ".tif") == 0)
    {
      return "image/tiff";
    }
    else if (strcmp(extension, ".tiff") == 0)
    {
      return "image/tiff";
    }
    else if (strcmp(extension, ".tr") == 0)
    {
      return "application/x-troff";
    }
    else if (strcmp(extension, ".trm") == 0)
    {
      return "application/x-msterminal";
    }
    else if (strcmp(extension, ".tsv") == 0)
    {
      return "text/tab-separated-values";
    }
    else if (strcmp(extension, ".txt") == 0)
    {
      return "text/plain";
    }
    else if (strcmp(extension, ".uls") == 0)
    {
      return "text/iuls";
    }
    else if (strcmp(extension, ".ustar") == 0)
    {
      return "application/x-ustar";
    }
    else if (strcmp(extension, ".vcf") == 0)
    {
      return "text/x-vcard";
    }
    else if (strcmp(extension, ".vrml") == 0)
    {
      return "x-world/x-vrml";
    }
    else if (strcmp(extension, ".wav") == 0)
    {
      return "audio/x-wav";
    }
    else if (strcmp(extension, ".wcm") == 0)
    {
      return "application/vnd.ms-works";
    }
    else if (strcmp(extension, ".wdb") == 0)
    {
      return "application/vnd.ms-works";
    }
    else if (strcmp(extension, ".wks") == 0)
    {
      return "application/vnd.ms-works";
    }
    else if (strcmp(extension, ".wmf") == 0)
    {
      return "application/x-msmetafile";
    }
    else if (strcmp(extension, ".wps") == 0)
    {
      return "application/vnd.ms-works";
    }
    else if (strcmp(extension, ".wri") == 0)
    {
      return "application/x-mswrite";
    }
    else if (strcmp(extension, ".wrl") == 0)
    {
      return "x-world/x-vrml";
    }
    else if (strcmp(extension, ".wrz") == 0)
    {
      return "x-world/x-vrml";
    }
    else if (strcmp(extension, ".xaf") == 0)
    {
      return "x-world/x-vrml";
    }
    else if (strcmp(extension, ".xbm") == 0)
    {
      return "image/x-xbitmap";
    }
    else if (strcmp(extension, ".xla") == 0)
    {
      return "application/vnd.ms-excel";
    }
    else if (strcmp(extension, ".xlc") == 0)
    {
      return "application/vnd.ms-excel";
    }
    else if (strcmp(extension, ".xlm") == 0)
    {
      return "application/vnd.ms-excel";
    }
    else if (strcmp(extension, ".xls") == 0)
    {
      return "application/vnd.ms-excel";
    }
    else if (strcmp(extension, ".xlt") == 0)
    {
      return "application/vnd.ms-excel";
    }
    else if (strcmp(extension, ".xlw") == 0)
    {
      return "application/vnd.ms-excel";
    }
    else if (strcmp(extension, ".xof") == 0)
    {
      return "x-world/x-vrml";
    }
    else if (strcmp(extension, ".xpm") == 0)
    {
      return "image/x-xpixmap";
    }
    else if (strcmp(extension, ".xwd") == 0)
    {
      return "image/x-xwindowdump";
    }
    else if (strcmp(extension, ".z") == 0)
    {
      return "application/x-compress";
    }
    else if (strcmp(extension, ".zip") == 0)
    {
      return "application/zip";
    }
  }
  return "application/octet-stream";
}